Learn R Programming

chronosphere (version 0.3.1)

[[,RasterArray,ANY,ANY-method: Indexing to extract RasterLayers of a RasterArray object

Description

Double bracket '[[' refers to layers' name in the RasterStack of the RasterArray. Use single brackets to extract elements based on their position in the RasterArray.

Usage

# S4 method for RasterArray,ANY,ANY
[[(x, i, drop = TRUE)

Arguments

x

RasterArray object.

i

subscript of the first dimension(rows) or vector-like subsetting.

drop

logical should the RasterStack be dropped and the element be reduced to a single RasterLayer?

Value

A RasterLayer or RasterArray class object.

Examples

Run this code
# NOT RUN {
data(dems)
# finds a layer
dems[["dem_30"]]
# returns a stack
dems[[c("dem_0", "dem_15")]]
# replaces a layervalues, but not the attributes of the layer
dem2 <- dems
dem2[["dem_0"]] <- dem2[["dem_5"]]
# compare every value in the 0 and 5 ma maps, they are all the same
mean(values(dem2[["dem_0"]]==dem2[["dem_5"]]))
# }

Run the code above in your browser using DataLab